<%@page language="java" pageEncoding="gb2312"%>
<%@page import="java.util.*"%>
<%@page import="com.mysql.jdbc.Driver"%>
<%@page import="java.sql.*"%>
<%@page import="com.mysql.jdbc.ResultSetMetaData"%>

<%

if(session.getAttribute("username")==null)
{
    response.sendRedirect("error.jsp");
}


String path = request.getContextPath();
String basePath = request.getScheme() + "://" + 
  request.getServerName() + ":" + request.getServerPort() + 
  path + "/";

String driverName = "com.mysql.jdbc.Driver";
String DBUser = "****";
String DBPasswd = "****";
String DBName = "****";

String connUrl = "jdbc:mysql://localhost/" + DBName + "?useUnicode=true&characterEncoding=utf-8&user=" + 
  DBUser + "&password=" + DBPasswd;

Class.forName(driverName).newInstance();
Connection conn = DriverManager.getConnection(connUrl);
Statement stmt = conn.createStatement();
stmt.executeQuery("SET NAMES UTF8");

request.setCharacterEncoding("GB2312");

String siteid = request.getParameter("siteid");
String s_city = request.getParameter("s_city");
String s_county = request.getParameter("s_county");
String s_town = request.getParameter("s_town");
String sitename = request.getParameter("sitename");
String longitude = request.getParameter("longitude");
String latitude = request.getParameter("latitude");

String sql = "update siteinfo set city = '" + s_city + "', county = '" + s_county + "', townorstreat = '" + s_town + "', sitename = '" + sitename + "', longitude = " + longitude + ", latitude = " + latitude + " where siteid = " + siteid;

out.println(sql);
stmt.executeUpdate(sql);

stmt.executeQuery("commit");  //save
conn.close();
stmt.close();

response.sendRedirect("siteinfo.jsp");
%>
